﻿Imports System.Data.SqlClient
Imports System.Configuration
Imports BEGestionProyecto
Public Class DLGPProyectoActividad

#Region "Consultar"


    Public Function fuDLBuscarProyectoActividadx(ByVal piPrycodProyectoActividad As Int32) As DataTable
        Try

            Dim lCnx As New SqlConnection(ConfigurationManager.ConnectionStrings("GPConnectionString").ConnectionString)
            Dim lCmd As New SqlCommand("paGPProyectoActividadBUSx", lCnx)
            lCmd.CommandType = CommandType.StoredProcedure
            lCmd.Parameters.Add("@paccodProyectoActividad", SqlDbType.Int).Value = piPrycodProyectoActividad
            Dim lDa As New SqlDataAdapter
            lDa.SelectCommand = lCmd
            'Llenar Dataset
            Dim lDs As New DataSet
            lDa.Fill(lDs)
            'Retornar Datos
            Return lDs.Tables(0)
        Catch ex As Exception
            Throw New ArgumentException("Descripcion : " & ex.Message)
            Return Nothing
        End Try

    End Function
    Public Function fuDLListarProyectoActividad() As DataTable
        Try

            Dim lCnx As New SqlConnection(ConfigurationManager.ConnectionStrings("GPConnectionString").ConnectionString)
            Dim lCmd As New SqlCommand("paGPProyectoActividadLST", lCnx)
            lCmd.CommandType = CommandType.StoredProcedure
            Dim lDa As New SqlDataAdapter
            lDa.SelectCommand = lCmd
            'Llenar el dataset
            Dim lDs As New DataSet
            lDa.Fill(lDs)
            'retornar datos
            Return lDs.Tables(0)
        Catch ex As Exception
            Throw New ArgumentException("Descripcion : " & ex.Message)
            Return Nothing
        End Try
    End Function
    Public Function fuDLListarActividadesPendientesxPersona(ByVal phorcodPersona As String) As DataTable
        Try

            Dim lCnx As New SqlConnection(ConfigurationManager.ConnectionStrings("GPConnectionString").ConnectionString)
            Dim lCmd As New SqlCommand("paGPActividadesPendientesxPersonaLST", lCnx)
            lCmd.CommandType = CommandType.StoredProcedure
            lCmd.Parameters.Add("@horcodPersona", SqlDbType.VarChar).Value = phorcodPersona
            Dim lDa As New SqlDataAdapter
            lDa.SelectCommand = lCmd
            'Llenar Dataset
            Dim lDs As New DataSet
            lDa.Fill(lDs)
            'Retornar Datos
            Return lDs.Tables(0)
        Catch ex As Exception
            Throw New ArgumentException("Descripcion : " & ex.Message)
            Return Nothing
        End Try
    End Function

    Public Function fuDLListarProyectoActividadxPersona(ByVal psPaccodProyecto As String, ByVal psHorcodPersona As String) As DataTable
        Try

            Dim lCnx As New SqlConnection(ConfigurationManager.ConnectionStrings("GPConnectionString").ConnectionString)
            Dim lCmd As New SqlCommand("paGPProyectoActividadPersonaLST", lCnx)
            lCmd.CommandType = CommandType.StoredProcedure
            lCmd.Parameters.Add("@papcodPersona", SqlDbType.VarChar).Value = psHorcodPersona
            lCmd.Parameters.Add("@paccodProyecto", SqlDbType.VarChar).Value = psPaccodProyecto

            Dim lDa As New SqlDataAdapter
            lDa.SelectCommand = lCmd
            'Llenar Dataset
            Dim lDs As New DataSet
            lDa.Fill(lDs)
            'Retornar Datos
            Return lDs.Tables(0)
        Catch ex As Exception
            Throw New ArgumentException("Descripcion : " & ex.Message)
            Return Nothing
        End Try
    End Function


#End Region
#Region "Actualizar"
    'Funcion que carga la Lista de Categorias del Personal
    'fecha crea         fecha modifica         autor
    '01/02/2012         01/02/2012              JKP
    Public Function fuDLInsertarProyecto(ByVal pBE As BEGPProyecto) As Boolean
        Try
            'Se crea una variable sqlconnection
            Dim lCnx As New SqlConnection(ConfigurationManager.ConnectionStrings("GPConnectionString").ConnectionString)
            'Se crea un sqlcommand
            Dim lCmd As New SqlCommand
            'Se crea la conexion para el command
            lCmd.Connection = lCnx
            'Se declara el typo de comando
            lCmd.CommandType = CommandType.StoredProcedure
            'Declaras el nombre del Store Procedure de Insertar Empleado
            lCmd.CommandText = "paGPProyectoINS"
            'Definicion de Parametros para el procedure
            With lCmd.Parameters
                .Add(New SqlParameter("@prycodProyecto", SqlDbType.VarChar)).Value = pBE.prycodProyecto
                .Add(New SqlParameter("@prycodLos", SqlDbType.SmallInt)).Value = pBE.prycodLos
                .Add(New SqlParameter("@prycodSls", SqlDbType.SmallInt)).Value = pBE.prycodSls
                .Add(New SqlParameter("@prycodSocio", SqlDbType.VarChar)).Value = pBE.prycodSocio
                .Add(New SqlParameter("@@prycodGerente", SqlDbType.VarChar)).Value = pBE.prycodGerente
                .Add(New SqlParameter("@prycodCliente", SqlDbType.VarChar)).Value = pBE.prycodCliente
                .Add(New SqlParameter("@prynumEncargo", SqlDbType.VarChar)).Value = pBE.prynumEncargo
                .Add(New SqlParameter("@@pryfecInicioProy", SqlDbType.DateTime)).Value = pBE.pryfecInicioProy
                .Add(New SqlParameter("@pryfecFinProy", SqlDbType.DateTime)).Value = pBE.pryfecFinProy
                .Add(New SqlParameter("@pryfecFinAmpliada", SqlDbType.DateTime)).Value = pBE.pryfecFinAmpliada
                .Add(New SqlParameter("@prymrkEstado", SqlDbType.Bit)).Value = pBE.prymrkEstado
                .Add(New SqlParameter("@prycodUserCrea", SqlDbType.Char)).Value = pBE.prycodUserCrea
                .Add(New SqlParameter("@pryfecCrea", SqlDbType.DateTime)).Value = pBE.pryfecCrea
                .Add(New SqlParameter("@prycodUserModifica", SqlDbType.Char)).Value = pBE.prycodUserModifica
                .Add(New SqlParameter("@pryfecModifica", SqlDbType.DateTime)).Value = pBE.pryfecModifica
            End With
            'Se cargan los parametros que viene de las entidades guardadas temporalmente
            lCmd.Parameters("@prycodProyecto").Value = pBE.prycodProyecto
            lCmd.Parameters("@prycodLos").Value = pBE.prycodLos
            lCmd.Parameters("@prycodSls").Value = pBE.prycodSls
            lCmd.Parameters("@prycodSocio").Value = pBE.prycodSocio
            lCmd.Parameters("@prycodGerente").Value = pBE.prycodGerente
            lCmd.Parameters("@prycodCliente").Value = pBE.prycodCliente
            lCmd.Parameters("@prynumEncargo").Value = pBE.prynumEncargo
            lCmd.Parameters("@pryfecInicioProy").Value = pBE.pryfecInicioProy
            lCmd.Parameters("@pryfecFinProy").Value = pBE.pryfecFinProy
            lCmd.Parameters("@pryfecFinAmpliada").Value = pBE.pryfecFinAmpliada
            lCmd.Parameters("@prymrkEstado").Value = pBE.prymrkEstado
            lCmd.Parameters("@prycodUserCrea").Value = pBE.prycodUserCrea
            lCmd.Parameters("@pryfecCrea").Value = pBE.pryfecCrea
            lCmd.Parameters("@prycodUserModifica").Value = pBE.prycodUserModifica
            lCmd.Parameters("@pryfecModifica").Value = pBE.pryfecModifica
            lCnx.Open()
            lCmd.ExecuteNonQuery()
            lCnx.Close()
            Return True
        Catch ex As Exception
            Throw New ArgumentException("Descripcion : " & ex.Message)
            Return False
        End Try
    End Function

#End Region


End Class

